local open = io.open
local strsplit = strsplit
local bind = bindings.Set
local modclick = bindings.SetModClickAction
local set = cvar.Register
local print = print
local assert = assert
local loadstring = loadstring

module("wtf")

local function reader(f)
	return function (f) return f:read() end, f
end

function Parse(filename)
	local f = assert(open(filename, "r"))
	
	for line in reader(f) do
		local action, name, value = strsplit(" ", line)
		
		action = action:lower()
		
		if action == "bind" then
			bind(name, value, true)
		elseif action == "modclick" then
			modclick(name, value)
		elseif action == "set" then
			set(name, loadstring("return "..value)())
		else
			print("Unknown action :", action)
		end
	end
	f:close()
end

